package pl.koszolko.documentclustering.cluster.document;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import pl.koszolko.documentclustering.dao.Author;
import pl.koszolko.documentclustering.dao.Document;

public abstract class DocumentForClustering  implements Comparable<DocumentForClustering>, Serializable{
	private static final long serialVersionUID = 1L;
	
	protected Document document;
	
	public DocumentForClustering() {		
	}
	
	public DocumentForClustering(Document document) {
		this.document = document;
	}
	
	public abstract double countSimilarity(DocumentForClustering document);
	
	public String getTitle() {
		return document.getTitle();
	}
	
	public Long getId() {
		return document.getId();
	}
	
	public String getDocumentClass() {
		return document.getDocumentClass();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((document == null) ? 0 : document.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DocumentForClustering other = (DocumentForClustering) obj;
		if (document == null) {
			if (other.document != null)
				return false;
		} else if (!document.equals(other.document))
			return false;
		return true;
	}
	
	
	@Override
	public int compareTo(DocumentForClustering o) {
		return (int) (getId() - o.getId());
	}

	public List<Author> getAuthors() {
		return document.getAuthors();
	}
	
	protected int getReferencesSize() {
		return this.document.getReferencesSize();
	}
	
	protected boolean ifReferencesContains(Document doc) {
		return this.document.ifReferencesContains(doc);
	}
	
	protected boolean ifCitedByContains(Document docCitedBy) {
		return document.ifCitedByContains(docCitedBy);
	}

	protected int getCitedBySize() {
		return document.getCitedBySize();
	}
	
	Set<Document> getCitedBy() {
		return document.getCitedBy();
	}
	
	Set<Document> getReferences() {
		return this.document.getReferences();
	}
}
